package ModelLayer;
import java.util.ArrayList;

/**
 * Write a description of class DvD here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class DvD
{
    // instance variables - replace the example below with your own
    private int id;
    private String title;
    private String artist;
    private String releaseDate;
    private ArrayList<DVDSample> dc;

    /**
     * Constructor for objects of class DvD
     */
    public DvD(int _id, String _title, String _artist, String _releaseDate)
    {
        // initialise instance variables
        id = _id;
        title = _title;
        artist = _artist;
        releaseDate = _releaseDate;
        dc = new ArrayList<DVDSample>();
    }

   //Get methods
    public int getId()
    {
        return id;
    }   
    public String getTitle()
    {
        return title;
    }  
    public String getArtist()
    {
        return artist;
    }  
    public String getReleaseDate()
    {
        return releaseDate;
    }  
    
    //Set methods
    public void setId(int newId)
    {
        id = newId;
    }
    public void setTitle(String newTitle)
    {
        title = newTitle;
    }
    public void setArtist(String newArtist)
    {
        artist = newArtist;
    }
    public void setReleaseDate(String newReleaseDate)
    {
        releaseDate = newReleaseDate;
    }
    
    public void addDVD(DVDSample d)
    {
        dc.add(d);
    }
    
    public DVDSample createDVDSample(int serialNr, String acqDate, double acqPrice)
    {
        DVDSample d = new DVDSample(serialNr, acqDate, acqPrice);
        
        return d;
    }

    public DVDSample findDVDSample(int serialNr)
    {
        int i = 0;
        boolean found = false;
        while(!found && i < dc.size())
        {
            DVDSample n = dc.get(i);
            if(serialNr == n.getSerialNr())
            {
                found = true;
            }
            else
            {
                i++;
            }
        }
        if(found)
        {
            return dc.get(i);
        }
        else
        {
            return null;
        }
    }
}
